# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Joakim Hernberg <jhernberg@alchemy.lu>
# Contributor: Ninez <triplesquarednine@gmail.com>

pkgname=tuna
pkgver=0.19
pkgrel=2
epoch=1
pkgdesc="Thread and IRQ affinity setting GUI and cmd line tool"
arch=(any)
url="https://rt.wiki.kernel.org/index.php/Tuna"
license=(GPL2)
groups=(realtime)
depends=(python-ethtool python-linux-procfs)
makedepends=(python-build python-installer python-setuptools python-wheel)
# python-inet_diag is not compatible with python3:
# https://bugs.archlinux.org/task/69208
optdepends=(
  'python-matplotlib: for oscilloscope'
  'python-numpy: for oscilloscope'
  'python-gobject: for oscilloscope'
)
backup=(etc/$pkgname.conf)
source=(https://git.kernel.org/pub/scm/utils/$pkgname/$pkgname.git/snapshot/$pkgname-$pkgver.tar.gz)
sha512sums=('b0c79ed10a72b4eebcc26217adf17fe9b66a06d308bfa9d294971892fb79353700e4eed9de84388bcb05275c141dfab4e6709d4faa4dd0079ea41adc342ec2aa')
b2sums=('64f23c0dbea9f73d4808371b083bbcddd91f22670a07820d7cf716335c8674d51c9230afb342b2f1788e036a753dac9a016d45edb05596f4b71d33913759d926')

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --no-isolation
}

package() {
  local _language _translation

  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -vDm 755 oscilloscope-cmd.py "$pkgdir/usr/bin/oscilloscope"
  install -vDm 644 $pkgname.desktop -t "$pkgdir/usr/share/applications/"
  install -vDm 755 $pkgname-cmd.py "$pkgdir/usr/bin/$pkgname"

  install -vDm 644 $pkgname/${pkgname}_gui.glade -t "$pkgdir/usr/share/$pkgname/"

  install -vDm 644 etc/$pkgname/example.conf -t "$pkgdir/etc/$pkgname/"
  install -vDm 644 etc/$pkgname.conf -t "$pkgdir/etc/"
  install -vDm 644 docs/oscilloscope+$pkgname.pdf -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 help/kthreads/* -t "$pkgdir/usr/share/$pkgname/help/kthreads"
  install -vDm 644 org.$pkgname.policy -t "$pkgdir/usr/share/polkit-1/actions/"
  install -vDm 644 docs/$pkgname.8 -t "$pkgdir/usr/share/man/man8/"

  # translations
  while read _language; do
    install -vdm 755 "$pkgdir/usr/share/locale/$_language/LC_MESSAGES"
    msgfmt po/$_language.po -o "$pkgdir/usr/share/locale/$_language/LC_MESSAGES/$pkgname.mo"
  done < po/LINGUAS
}
# vim:set ts=2 sw=2 et:
